<?php

namespace core\base;


use core\exception\CommonException;
use yii\db\ActiveQuery;

class BaseQuery extends ActiveQuery
{
    /**
     * 翻页
     * @param $page
     * @param int $pageCount
     * @return $this
     * @throws CommonException
     */
    public function page($page, $pageCount = 25)
    {
        if ($page <= 0) {
            throw new CommonException('page number is illegal', 500);
        }
        $this->limit($pageCount);
        $_offset = ($page - 1) * $pageCount;
        $this->offset($_offset);
        return $this;
    }
}